package guoanmaker.operator.business.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import guoanmaker.operator.business.model.InRoundPhone;
import guoanmaker.operator.business.service.OperatorLeaseSpaceNewServiceInterface;
import guoanmaker.operator.helper.common.AjaxJson;
import guoanmaker.operator.helper.common.abstractobj.ApiController;
import io.swagger.annotations.ApiOperation;
/**
 * 
    * @ClassName: OperatorLeaseSpaceNewController  
    * @Description: 新版租赁空间接口  
    * @author lsy  
    * @date 2017年12月16日 下午1:15:47    
    *
 */
@RestController
@RequestMapping(ApiController.OPERATOR_LEASE_SPACE_NEW)
public class OperatorLeaseSpaceNewController {
	@Autowired
	private OperatorLeaseSpaceNewServiceInterface operatorLeaseSpaceNewServiceInterface;
	
	/**
	 * 
	    * @Title: saveOperatorLeaseSpaceNew  
	    * @Description: 保存新版租赁空间  
	    * @param @param inRoundPhone
	    * @param @return      
	    * @return AjaxJson      
	    * @throws
	 */
	@ApiOperation(value = "保存新版租赁空间", notes = "保存新版租赁空间")
	@PostMapping("saveOperatorLeaseSpaceNew")
	public AjaxJson saveOperatorLeaseSpaceNew(@RequestBody InRoundPhone inRoundPhone) {
		AjaxJson ajaxJson=new AjaxJson();
		try {
			operatorLeaseSpaceNewServiceInterface.deleteByCityCode(inRoundPhone);
			operatorLeaseSpaceNewServiceInterface.saveOperatorLeaseSpaceNew(inRoundPhone);
			ajaxJson.setSuccess(true).setStatus(200).setData(null).setMsg("操作成功");
		} catch (Exception e) {
			ajaxJson.setSuccess(false).setStatus(500).setData(null).setMsg("操作失败");
			
		}
		return ajaxJson;
	}
	
	/**
	 * 
	    * @Title: selectProvideRoom  
	    * @Description: 查询空间  
	    * @param @param spaceNumber
	    * @param @return      
	    * @return AjaxJson      
	    * @throws
	 */
	@ApiOperation(value = "查询空间", notes = "根据空间编号查询空间")
	@PostMapping("selectProvideRoom")
	public AjaxJson selectProvideRoom(String spaceNumber) {
		AjaxJson ajaxJson=new AjaxJson();
		try {
			ajaxJson.setSuccess(true).setStatus(200).setData(operatorLeaseSpaceNewServiceInterface.selectProvideRoom(spaceNumber)).setMsg("操作成功");
		} catch (Exception e) {
			e.printStackTrace();
			ajaxJson.setSuccess(false).setStatus(500).setData(null).setMsg("操作失败");
		}
		return ajaxJson;
	}
	
	/**
	 * 
	    * @Title: findOperatorLeaseSpaceNewByCityCode  
	    * @Description:根据citycode 查询配置的租赁空间   
	    * @param @param cityCode
	    * @return AjaxJson      
	    * @throws
	 */
	@ApiOperation(value = "根据citycode查询空间", notes = "根据citycode查询空间")
	@PostMapping("findAllOperatorLeaseSpaceNew")
	public AjaxJson findOperatorLeaseSpaceNewByCityCode(String cityId) {
		AjaxJson ajaxJson=new AjaxJson();
		try {
			ajaxJson.setSuccess(true).setStatus(200).setData(operatorLeaseSpaceNewServiceInterface.findOperatorLeaseSpaceNewByCityCode(cityId)).setMsg("操作成功");
		} catch (Exception e) {
			ajaxJson.setSuccess(false).setStatus(500).setData(null).setMsg("操作失败");
		}
		return ajaxJson;
	}

}
